home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F37308_testCurry.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-16  |  1.4 KB  |  45 lines

  1. <xsl:stylesheet version="1.0" 
  2.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.  xmlns:saxon="http://icl.com/saxon"
  4.  xmlns:myMultiply="f:myMultiply"
  5.  exclude-result-prefixes="saxon myMultiply "
  6.  >
  7.  
  8.  <xsl:import href="curry.xsl"/>
  9.  
  10.   <xsl:output omit-xml-declaration="yes" indent="yes"/>
  11.  
  12.   <myMultiply:myMultiply/>     <!-- My multiply x y function -->
  13.  
  14.   <xsl:template match="/">
  15.     <xsl:variable name="vMyMultiply"
  16.                   select="document('')/*/myMultiply:*[1]"/>
  17.     
  18.     <!-- Get the curried fn here -->
  19.     <!-- Get the partial application (*5) -->
  20.     <xsl:variable name="vrtfCurriedMultBy5"> 
  21.       <xsl:call-template name="curry">
  22.         <xsl:with-param name="pFun" select="$vMyMultiply"/>
  23.         <xsl:with-param name="pNargs" select="2"/>
  24.         <xsl:with-param name="arg1" select="5"/>
  25.       </xsl:call-template>
  26.     </xsl:variable>
  27.     
  28.     <xsl:variable name="vMultBy5"
  29.                   select="saxon:node-set($vrtfCurriedMultBy5)/*"/>
  30.  
  31.  
  32.     <xsl:apply-templates select="$vMultBy5"> <!-- Apply (*5) on 2 -->
  33.       <xsl:with-param name="arg2" select="2"/>
  34.     </xsl:apply-templates> <!-- The result must be 10 -->
  35.  
  36.   </xsl:template>
  37.   
  38.   <xsl:template match="myMultiply:*">
  39.     <xsl:param name="arg1"/>
  40.     <xsl:param name="arg2"/>
  41.     
  42.     <xsl:value-of select="$arg1 * $arg2"/>
  43.   </xsl:template>
  44.  
  45. </xsl:stylesheet>